package com.gxsyh.nantie.phone.regist.management.provider.service.impl;

import com.gxsyh.nantie.phone.regist.management.provider.domain.TbUser;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.gxsyh.nantie.phone.regist.management.provider.mapper.TbUserMapper;
import com.gxsyh.nantie.phone.regist.management.provider.service.TbUserService;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 *@Author hua96
 *@Date   2020-02-24
 *@Time   12:20
 *@Version 1.0.0
 */
@Service
public class TbUserServiceImpl implements TbUserService{

    @Resource
    private TbUserMapper tbUserMapper;


    @Override
    public List<TbUser> selectAll() {
        List<TbUser> userList = tbUserMapper.selectAll();
        return userList;
    }

    @Override
    public void updateUserState(Long id){
        TbUser tbUser = tbUserMapper.selectByPrimaryKey(id);
        Example example = new Example(TbUser.class);
        Example.Criteria criteria = example.createCriteria();
        //where条件 update tb_user set tb_user.user_status = 1 where id=?
        criteria.andEqualTo("id",id);
        tbUser.setUserStatus(1);
        tbUserMapper.updateByExample(tbUser,example);
    }
}
